var mongo = require('../model/mongoose.js');
var tools = require('../tools/utils.js');
var userschema = {
    username: String,
    password: String,
    _id: {
        type: String,
        unique: true
    }
};
var model = mongo('web_user', userschema, 'web_user').model;

module.exports.reg = function(user, cb) {
    model.create(user, function(err) {
        tools.execCB(cb, err, null);
    });
};
module.exports.checkUser = function(user) {
    model.find({ username: user.username, password: user.pwd }, function(err, result) {
        if (err) {
            return false;
        } else if (result.length < 0) {
            return false;
        } else {
            return true;
        }

    });
};
